package com.kgo.eidtor.controller;

import com.kgo.eidtor.entity.UserBean;
import com.kgo.eidtor.service.UserService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author keepgoon
 * @Description: TODO
 * @date 2019/2/1415:53
 */
@RestController
@CrossOrigin
public class UserCountroller {
    @Resource
    private UserService userService;

    @RequestMapping(value = "/user/id" ,method = RequestMethod.GET,produces="text/plain;charset=UTF-8")
    public String getUserInfoById(String id){
        return userService.getUserInfoById(id);
    }

    /**
     * 新增用户
     * @param user
     * @return
     */
    @RequestMapping(value = "/user" ,method = RequestMethod.POST,produces="text/plain;charset=UTF-8")
    public String addUser(UserBean user){
        return userService.addUser(user);
    }
    @RequestMapping(value = "/user" ,method = RequestMethod.GET,produces="text/plain;charset=UTF-8")
    public String getUsers(UserBean user){
        user.setpaging();//开启分页
        return userService.getUsers(user);
    }
}
